package gjtx3;

import java.util.ArrayList;
import java.util.List;

public class Company {
    private String companyName;
    private String site;
    private String phone;
    private String manage;
    Staff st=new Staff();
    List list=new ArrayList();

    public Company(String companyName, String site, String phone, String manage) {
        this.companyName = companyName;
        this.site = site;
        this.phone = phone;
        this.manage = manage;
    }

    public Company() {
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getSite() {
        return site;
    }

    public void setSite(String site) {
        this.site = site;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getManage() {
        return manage;
    }

    public void setManage(String manage) {
        this.manage = manage;
    }
    public void show(){
        System.out.println("公司:"+companyName+"地址在"+site);
    }
    //招聘员工（要求工号不能重复）(在员工类中重写equals方法！！！)
    public boolean recruit(String name,int nianL,String xingB,String zhiW,int xinShui,String number){
        st=new Staff(name,nianL,xingB,zhiW,xinShui,number);
        for (Object s:list){
            if (s.equals(st))
                return false;
        }
        list.add(st);
        System.out.println("已招聘！ ");
        return true;
    }
    //输出员工信息
    public void output(){
        System.out.println("员工信息如下：");
        for (Object a:list)
            System.out.println(a);
    }
    //辞退员工
    public boolean delete(String number){
        for (int i=0;i<list.size();i++) {
            Staff a=(Staff)list.get(i);
            if (a.getNumber().equals(number)) {
               list.remove(i);
                System.out.println("已辞退！");
                return true;
            }
        }
        System.out.println("未找到！");
        return false;
    }
    public void statistics(){
        System.out.println("总共有"+list.size()+"人。");
    }
   public Staff salary(){
        if (list.size()>0) {
            Staff s = (Staff) list.get(0);
            for (int i = 0; i < list.size(); i++) {
                Staff a = (Staff) list.get(i);
                if (a.getXinShui()>=s.getXinShui()){
                    s=a;
                }
            }
            System.out.println(s);
            return s;
        }
       System.out.println("未找到！");
       return null;
   }
}
